<?php

/**
 * 开发者Domain 类
 * @author: 喵了个咪  <wenzhenxi@vip.qq.com> 2015-07-23
 */
class Domain_Project {

    /**
     * 获取项目清单
     */
    public function getProjectList() {

        $Model_Project = new Model_Project();
        return $Model_Project->getProjectList();
    }

    /**
     * 获取项目清单
     */
    public function getProjectIdList() {

        $Model_Project = new Model_Project();
        return $Model_Project->getProjectIdList();
    }

    /**
     * 关联权限和项目
     */
    public function setProjectOrPrivilege($pId, $priId) {

        //删除原有关联
        $this->delProjectOrPrivilege($priId);
        //关联权限ID和项目ID
        $Model_ProjectPrivilege = new Model_ProjectPrivilege();
        $Model_ProjectPrivilege->setpriIdOrProjectId($pId, $priId);
    }

    /**
     * 删除权限和项目关联
     */
    public function delProjectOrPrivilege($priId) {

        $Model_ProjectPrivilege = new Model_ProjectPrivilege();
        $Model_ProjectPrivilege->delpriIdOrProjectId($priId);
    }

    /**
     * 验证项目是否存在
     */
    public function validationProject($pId) {

        //通过名字获取ID
        $Model_Project = new Model_Project();
        $rs            = $Model_Project->getIdByNmae($pId);
        if (!$rs) {
            throw new PhalApi_Exception_BadRequest(T('No Project'));
        }
    }
}